import func from './func';
class Singleton implements func {
  private static _instance: Singleton = new Singleton();
  private username: string;
  private address: string[] = [
    '0x000000000000000000000000763af809531e14c7f7a02e82eb7e067b941c7a85',
    '0x00000000000000000000000030651aa285caafd8dc47788cc2fa660065cd841d',
    '0x0000000000000000000000000b00b9f5aa7d4b0c1570493febc4f614c879ee74',
    '0x000000000000000000000000c332d654bbdbecdba65e686cac399eb391901f77'
  ];
  private companyname: string[] = [
    '华为',
    '京东方',
    '蓝思科技',
    '银行'
  ];
  private companyEnglishName:string[] = [
    'huawei',
    'jingdongfang',
    'lansikeji',
    'bank'
  ];
  public static getInstance() {
    return this._instance;
  }
  public getUserName(): string {
    return this.username;
  }
  public setUserName(name: string): void {
    this.username = name;
  }
  public name2add(name: string): string {
    for(let i = 0; i < 4; i++) {
      if (this.companyEnglishName[i] === name) {
        return this.address[i];
      }
    }
  }
  public add2name(add: string): string {
    for(let i = 0; i < 4; i++) {
      if (this.address[i] === add) {
        return this.companyname[i];
      }
    }
  }
  public add2enname(add: string): string {
    for(let i = 0; i < 4; i++) {
      if (this.address[i] === add) {
        return this.companyEnglishName[i];
      }
    }
  }
  public zh2en(name: string): string {
    for(let i = 0; i < 4; i++) {
      if (this.companyname[i] === name) {
        return this.companyEnglishName[i];
      }
    }
  }
}
export default Singleton;